<?php

namespace Common\Model\Cache;

class Url extends Base
{
    public function refresh()
    {
        $url = M("Url")->where(' is_display = 1 ')->select();
        foreach ($url as $v) {
            $list[$v['alias']] = $v;
            $configURL[$v['rule_key']] = $v['rule_var'];
        }
        $this->save($list);
        //写入路由配置文件
        $path = APP_PATH . 'Home/Conf/url.php';
        $config_arr['URL_ROUTER_ON'] = (bool)C('YTATA_URL_RULE_OPEN');
        $config_arr['URL_ROUTE_RULES'] = $configURL;
        $this->saveConfig($path, $config_arr);
        return $list;
    }
}